package org.opens.kafka.service.impl;

import lombok.extern.slf4j.Slf4j;
import org.opens.kafka.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
@Slf4j
public class MessageServiceKafkaImpl implements MessageService {

    @Resource
    private KafkaTemplate<String, String> kafkaTemplate;

    @Override
    public void sendMessage(String id) {
        log.info("向kafka发送消息: {}", id);
        kafkaTemplate.send("test-kafka", id);
    }
}
